//手机验证
var timer;
var sending = 0;
$(document).ready(function(){
	var path = "http://v.gaodun.com";
	if(typeof(GAODUNER) != "undefined")
		path = GAODUNER.path;

	//顶部登录
	$("#hlbutton").click(function(){
		/*$('#headloginForm').ajaxForm({
			beforeSubmit:  checkForm, // 表单提交执行前检测
			success:       complete,  // 表单提交后执行函数
			dataType: 'json'
		});*/
		
		if(checkForm()){
			var formdata = $("#headloginForm").serialize(); //序列化表单数据
			var url = path+"/Member/checklogin?callback=?";
			$.getJSON(url,formdata,function(data){
				complete(data);
			});
			return false;
		}else{
			return false;
		}
		
		function checkForm(){
			//return $.formValidator.pageIsValid('1');
			var p1 =/^1\d{10}$/;
			var p2=/^([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
			if(!p1.test($("#huser_account").val())&&!p2.test($("#huser_account").val())){
				info = '请输入邮箱或者手机号';
				$("#hlfailTips").html(info).show();
				return false;
			}
			if(!$("#hlpassword").val()){
				info = '请输入密码';
				$("#hlfailTips").html(info).show();
				return false;
			}else{
				return true;
			}
		}
		function complete(data){
			//eval("var data = " + data + ";") ;
			if(data.status==1){
				$("#hlsuccessTips").html(data.info);
				//$("#hlsuccessTips").html(data.msg);
				/*$(".lgAfter span").first().find('img').attr("src",path+"/Avatar");
				$(".lgAfter span").first().find('em').first().html(data.username);
				$.unblockUI();//关闭登录弹出层
				$(".lgBefore").hide();
				$(".lgAfter").show();
				if ( $("#loginWrap").length > 0 ) {
					$("#loginWrap").remove();
				}
				if ( $("#supersized").length > 0 ) {
					$("#supersized").remove();
				}*/
				setTimeout(function(){window.location.href=path+"/Class";}, 1000);
			}else{
				$("#hlfailTips").html(data.info).show();
				//$("#hlfailTips").html(data.msg).show();
			}
		}
	});
	/*$.formValidator.initConfig({
		onerror:function(msg){
			//$("#failTips").html(msg).show();
			return false;
		}
	});*/
	/*------------------------------------------------------------------*/
	/*$("#huser_account").formValidator({onfocus:"请输入邮箱或者手机号",oncorrect:"谢谢您的合作"}).regexValidator({regexp:["email","mobile"],datatype:"enum",onerror:"你输入的手机或邮箱格式不正确"});
	
	$("#hlpassword").formValidator({onshow:"请输入密码",onfocus:"密码为6-20位!",oncorrect:"密码合法"}).inputValidator({min:6,max:20,empty:{leftempty:false,rightempty:false,emptyerror:"密码两边不能有空符号"},onerror:"密码格式不正确,请确认"});*/
	/*------------------------------------------------------------------*/

});
